﻿// ———————————————————————–
// <copyright file="ResourceEIDDStatusCode.cs" company="The MITRE Corporation">
//    Copyright (c) 2014 The MITRE Corporation. All rights reserved.
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
// </copyright>
// ———————————————————————–
/////////////////////////////////////////////////////////////////////////////////////////////////
// ResourceEIDDStatusCode.cs:
// Unit statuses based off of NENA/APCO EIDD.
// Project: IC.NET - EDXL Library
//
// Language:    C#, .NET 4.0
// Platform:    Windows 7, VS 2012
// Author:      Jim Cronin MITRE Bedford

/////////////////////////////////////////////////////////////////////////////////////////////////

// Copyright (c) 2014 The MITRE Corporation. All rights reserved.
//
// NOTICE
// This software was produced for the U. S. Government
// under Contract No. FA8721-09-C-0001, and is
// subject to the Rights in Noncommercial Computer Software
// and Noncommercial Computer Software Documentation Clause
// (DFARS) 252.227-7014 (JUN 1995)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EDXLSharp.NIEMCADLib
{
  /// <summary>
  /// Unit statuses based off of NENA/APCO EIDD.
  /// </summary>
  public enum ResourceEIDDStatusCode
  {
    /// <summary>
    /// Emergency unit acknowledged receipt of a dispatch/assignment
    /// </summary>
    AcknowledgedTransmission,
    /// <summary>
    /// Emergency unit is at an alternate location when used as a standalone secondary status or is en route to, transporting to, arrived at, etc. when used in combination with another secondary unit status-common 
    /// </summary>
    AlternateLocation,
    /// <summary>
    /// Emergency unit arrived at the incident location or at some other location
    /// </summary>
    Arrived,
    /// <summary>
    /// Emergency unit has been assigned to an incident or to some other event
    /// </summary>
    Assigned,
    /// <summary>
    /// Emergency unit's assignment to an activity has been cancelled. This is an observation useful for tracking unit history and incident progress 
    /// </summary>
    AssignmentCancelled,
    /// <summary>
    /// Emergency unit is back to patrolling or covering its assigned area, beat, or district. This is an observation useful for tracking unit history
    /// </summary>
    BackToAssignedArea,
    /// <summary>
    /// Emergency unit is backing up another emergency unit on an incident
    /// </summary>
    BackUp,
    /// <summary>
    /// Emergency unit is on a break
    /// </summary>
    Break,
    /// <summary>
    /// Emergency unit checked in with its dispatcher. This is an observation useful for tracking unit history and incident progress
    /// </summary>
    CheckedIn,
    /// <summary>
    /// Emergency unit cleared the incident location or some other location
    /// </summary>
    Cleared,
    /// <summary>
    /// Emergency unit is involved in Community Oriented Policing or Problem Oriented Policing activities
    /// </summary>
    COPPOP,
    /// <summary>
    /// Emergency unit is assigned to Court
    /// </summary>
    Court,
    /// <summary>
    /// Emergency unit is patrolling, has moved up, or is covering an alternate area, beat, station, or district when used as a standalone secondary status or is
    /// </summary>
    CoveringAlternateArea,
    /// <summary>
    /// Emergency Unit is off duty
    /// </summary>
    OffDuty,
    /// <summary>
    /// Emergency unit is on duty
    /// </summary>
    OnDuty,
    /// <summary>
    /// Emergency Unit is located at the scene (location) of the incident
    /// </summary>
    OnScene,
    /// <summary>
    /// Emergency unit is out of service
    /// </summary>
    OutOfService,
    /// <summary>
    /// Emergency responders made contact with a patient involved in the incident. This is an observation useful for tracking unit history and incident progress
    /// </summary>
    PatientContact,
    /// <summary>
    /// Emergency unit is at a post when used as a standalone secondary unit status-common or is en route to, arrived at, etc. when used in combination with another secondary unit status-common
    /// </summary>
    Post,
    /// <summary>
    /// Emergency unit is on a self initiated event that is not a traffic stop
    /// </summary>
    ResponderInitiatedEvent,
    /// <summary>
    /// Emergency unit is at Roll Call when used as a standalone secondary unit status-common or is en route to, arrived at, etc. when used in combination with another secondary unit status common
    /// </summary>
    RollCall,
    /// <summary>
    /// Emergency unit has automatically been activated, but is not yet available and has not checked in
    /// </summary>
    Roster,
    /// <summary>
    /// Emergency unit’s end of shift is pending
    /// </summary>
    ShiftPending,
    /// <summary>
    /// Emergency unit is at an incident's staging location when used as a standalone secondary unit status common or is en route to, arrived at, etc. when used in combination with another secondary unit status-common
    /// </summary>
    Staging,
    /// <summary>
    /// Emergency unit is at its headquarters, station, or substation when used as a standalone secondary unit status-common or is en route to, transporting to, arrived at, etc. when used in combination with another secondary unit status-common
    /// </summary>
    Station,
    /// <summary>
    /// Emergency unit is on scene at a self initiated traffic stop
    /// </summary>
    TrafficStop,
    /// <summary>
    /// Emergency unit and responders are participating in a training activity
    /// </summary>
    Training,
    /// <summary>
    /// Emergency unit is transporting or escorting a person or equipment to a location or destination
    /// </summary>
    Transporting,
    /// <summary>
    /// Emergency unit is not adequately staffed 
    /// </summary>
    Unmanned
  }

  public static class ResourceEIDDStatusCodeHelper
  {
    /// <summary>
    /// Gets the text to be written to XML for this status code
    /// </summary>
    /// <param name="code"></param>
    /// <returns></returns>
    public static string GetText(this ResourceEIDDStatusCode code)
    {
      switch (code)
      {
        case ResourceEIDDStatusCode.AcknowledgedTransmission:
          return "ACKNOWLEDGED TRANSMISSION";
        case ResourceEIDDStatusCode.AlternateLocation:
          return "ALTERNATE LOCATION";
        case ResourceEIDDStatusCode.Arrived:
          return "ARRIVED";
        case ResourceEIDDStatusCode.Assigned:
          return "ASSIGNED";
        case ResourceEIDDStatusCode.AssignmentCancelled:
          return "ASSIGNMENT CANCELED";
        case ResourceEIDDStatusCode.BackToAssignedArea:
          return "BACK TO ASSIGNED AREA";
        case ResourceEIDDStatusCode.BackUp:
          return "BACK UP";
        case ResourceEIDDStatusCode.Break:
          return "BREAK";
        case ResourceEIDDStatusCode.CheckedIn:
          return "CHECKED IN";
        case ResourceEIDDStatusCode.Cleared:
          return "CLEARED";
        case ResourceEIDDStatusCode.COPPOP:
          return "COP/POP";
        case ResourceEIDDStatusCode.Court:
          return "COURT";
        case ResourceEIDDStatusCode.CoveringAlternateArea:
          return "COVERING ALTERNATE AREA";
        case ResourceEIDDStatusCode.OffDuty:
          return "OFF DUTY";
        case ResourceEIDDStatusCode.OnDuty:
          return "ON DUTY";
        case ResourceEIDDStatusCode.OnScene:
          return "ON SCENE";
        case ResourceEIDDStatusCode.OutOfService:
          return "OUT OF SERVICE";
        case ResourceEIDDStatusCode.PatientContact:
          return "PATIENT CONTACT";
        case ResourceEIDDStatusCode.Post:
          return "POST";
        case ResourceEIDDStatusCode.ResponderInitiatedEvent:
          return "RESPONDER INITIATED EVENT";
        case ResourceEIDDStatusCode.RollCall:
          return "ROLL CALL";
        case ResourceEIDDStatusCode.Roster:
          return "ROSTER";
        case ResourceEIDDStatusCode.ShiftPending:
          return "SHIFT PENDING";
        case ResourceEIDDStatusCode.Staging:
          return "STAGING";
        case ResourceEIDDStatusCode.Station:
          return "STATION";
        case ResourceEIDDStatusCode.TrafficStop:
          return "TRAFFIC STOP";
        case ResourceEIDDStatusCode.Training:
          return "TRAINING";
        case ResourceEIDDStatusCode.Transporting:
          return "TRANSPORTING";
        case ResourceEIDDStatusCode.Unmanned:
          return "UNMANNED";
        default:
          throw new ArgumentOutOfRangeException("Not a valid/Known value for ResourceEIDDStatusCode");
      }
    }

    /// <summary>
    /// Converts a text value to a ResourcePrimaryStatusCode
    ///  - First checks for the XML text of each code
    ///  - Lastly just calls Enum.Parse
    /// </summary>
    /// <param name="value">String to parse</param>
    /// <returns>ResourcePrimaryStatusCode described by value</returns>
    /// <exception cref="System.ArgumentNullException">Thrown if value is null</exception>
    /// <exception cref="System.ArgumentException">Thrown if value is empty or whitespace</exception>
    /// <exception cref="System.OverflowException">Thrown if value does not represent a ResourcePrimaryStatusCode</exception>
    public static ResourceEIDDStatusCode GetCode(string value)
    {
      switch (value)
      {
        case "ACKNOWLEDGED TRANSMISSION":
          return ResourceEIDDStatusCode.AcknowledgedTransmission;
        case "ALTERNATE LOCATION":
          return ResourceEIDDStatusCode.AlternateLocation;
        case "ARRIVED":
          return ResourceEIDDStatusCode.Arrived;
        case "ASSIGNED":
          return ResourceEIDDStatusCode.Assigned;
        case "ASSIGNMENT CANCELED":
          return ResourceEIDDStatusCode.AssignmentCancelled;
        case "BACK TO ASSIGNED AREA":
          return ResourceEIDDStatusCode.BackToAssignedArea;
        case "BACK UP":
          return ResourceEIDDStatusCode.BackUp;
        case "BREAK":
          return ResourceEIDDStatusCode.Break;
        case "CHECKED IN":
          return ResourceEIDDStatusCode.CheckedIn;
        case "CLEARED":
          return ResourceEIDDStatusCode.Cleared;
        case "COP/POP":
          return ResourceEIDDStatusCode.COPPOP;
        case "COURT":
          return ResourceEIDDStatusCode.Court;
        case "COVERING ALTERNATE AREA":
          return ResourceEIDDStatusCode.CoveringAlternateArea;
        case "OFF DUTY":
          return ResourceEIDDStatusCode.OffDuty;
        case "ON DUTY":
          return ResourceEIDDStatusCode.OnDuty;
        case "ON SCENE":
          return ResourceEIDDStatusCode.OnScene;
        case "OUT OF SERVICE":
          return ResourceEIDDStatusCode.OutOfService;
        case "PATIENT CONTACT":
          return ResourceEIDDStatusCode.PatientContact;
        case "POST":
          return ResourceEIDDStatusCode.Post;
        case "RESPONDER INITIATED EVENT":
          return ResourceEIDDStatusCode.ResponderInitiatedEvent;
        case "ROLL CALL":
          return ResourceEIDDStatusCode.RollCall;
        case "ROSTER":
          return ResourceEIDDStatusCode.Roster;
        case "SHIFT PENDING":
          return ResourceEIDDStatusCode.ShiftPending;
        case "STAGING":
          return ResourceEIDDStatusCode.Staging;
        case "STATION":
          return ResourceEIDDStatusCode.Station;
        case "TRAFFIC STOP":
          return ResourceEIDDStatusCode.TrafficStop;
        case "TRAINING":
          return ResourceEIDDStatusCode.Training;
        case "TRANSPORTING":
          return ResourceEIDDStatusCode.Transporting;
        case "UNMANNED":
          return ResourceEIDDStatusCode.Unmanned;
        default:
          return (ResourceEIDDStatusCode)Enum.Parse(typeof(ResourceEIDDStatusCode), value);
      }
    }
  }
}